{extend name="common/userbase"} 
{block name="header_js"}
<link href="__STATICS__/css/Orders.css" rel="stylesheet" type="text/css" />
<script src="__STATICS__/js/jquery.reveal.js" type="text/javascript"></script>
<script src="__STATICS__/js/jquery.sumoselect.min.js" type="text/javascript"></script>
<script src="__STATICS__/js/footer.js" type="text/javascript"></script>
 <script type="text/javascript">
      $(document).ready(function () {
          window.asd = $('.SlectBox').SumoSelect({ csvDispCount: 3 });
          window.test = $('.testsel').SumoSelect({okCancelInMulti:true });
      });
  </script>
{/block}
{block name="title"}
<title>确认订单界面</title>
{/block}

{block name="content"}
<div id="Orders" class="Inside_pages  clearfix">
    <div class="Orders_style clearfix">
       <div class="address clearfix">
         <div class="title">收货人信息</div>
            <div class="adderss_list clearfix">
              <div class="title_name">选择收货地址 <a href="{:url('user/address')}">+添加地址</a></div>
               <!--<div class="list" id="select">
              <ul class="confirm active">
              <div class="default">默认地址</div>
              <div class="adderss_operating">
               <div class="Operate"><a href="#" class="delete_btn"></a> <a href="#" class="modify_btn"></a></div>
              </div>
              <div class="user_address">
              <li>小张</li>
              <li>四川成都高新区创业路10号3栋1单元1102式</li>
              <li class="Postcode">610043</li>      
              <li>18908269130</li>
              </div>
              </ul>
               <ul class="">
                <div class="adderss_operating">
               <div class="Operate"><a href="#" class="delete_btn"></a> <a href="#" class="modify_btn"></a></div>
              </div>
               <div class="user_address">
              <li>小张</li>
              <li>四川成都高新区创业路10号3栋1单元1102式</li>
              <li class="Postcode">610043</li>
              <li>18908269130</li>
              </div>
              </ul>
               <ul class="">
                <div class="adderss_operating">
               <div class="Operate"><a href="#" class="delete_btn"></a> <a href="#" class="modify_btn"></a></div>
              </div>
               <div class="user_address">
              <li>小张</li>
              <li>四川成都高新区创业路10号3栋1单元1102式</li>
              <li class="Postcode">610043</li>
              <li>18908269130</li>
              </div>
              </ul>
              </div>
             </div>
  -->        <!--收货地址样式-->
      
       <div class="Shipping_address">
          {foreach name="address" id="val"}
         <ul class="detailed">
          <li><label>收货人姓名</label><span>{$val.username}</span></li>
          <li><label>电子邮件</label><span>{$val.email}</span></li>
          <li><label>详细地址</label><span>{$val.area}{$val.address}</span></li>
          <li><label>邮政编码</label><span>{$val.postcodes}</span></li>
          <li><label>移动电话</label><span>{$val.phone}</span></li> 
           <li><label>固定电话</label><span></span></li>        
         </ul>
         {/foreach}
       </div>
       </div> 
         <form class="form" method="get" >  
      <fieldset> 
        
       <!--产品列表-->
       <div class="Product_List">
       
        <table>
         <thead><tr class="title"><td class="name">商品名称</td><td class="price">商品价格</td><td class="Preferential">优惠价</td><td class="Quantity">购买数量</td><td class="Money">金额</td></tr></thead>
         <tbody>
          {foreach name="shop" id="val"}
         <tr>
          <td class="Product_info">
           <a href="#"><img src="__UPLOADS__/{$val.img}" width="100px" height="100px"/></a>
           <a href="#" class="product_name">{$val.name}</a>
           </td>
          <td><i>￥</i><span class="discount">{$val.discount}</span></td>
          <td><i>￥</i><span>0</span></td>
          <td class="number">{$val.number}</td>
          <td class="Moneys"><i>￥</i><span class="sum"></span></td>
         </tr>
         {/foreach}
         </tbody>
        </table>
        <div class="Pay_info">
         <label>订单留言</label><input name="mess" type="text"  onkeyup="checkLength(this);" class="text_name " />  <span class="wordage">剩余字数：<span id="sy" style="color:Red;">50</span></span>  
        </div>
        <!--价格-->
        <div class="price_style">
        <div class="right_direction">
          <ul>
           <li><label>商品总价</label><i>￥</i><span class="total" name="total">0</span></li>
           <li><label>优惠金额</label><i>￥</i><span class="preferential">23.00</span></li>
           <li><label>配&nbsp;&nbsp;送&nbsp;&nbsp;费</label><i>￥</i><span>0</span></li>
           <li class="shiji_price"><label>实&nbsp;&nbsp;付&nbsp;&nbsp;款</label><i>￥</i><span class="disbursements">0</span></li>    
          </ul>   
          <div class="btn"><input name="submit" type="button" value="提交订单" class="submit_btn"/> <input name="back" type="button" value="返回购物车"  class="return_btn"/></div>
           <div class="integral right">待订单确认后，你将获得<span id="integral" name="integral">0</span>积分</div>
        </div>
        </div>
       </div>  
       </fieldset>
          </form>
    </div>
  </div>

  </div>
{/block}
{block name="footer_js"}
<script>
  function sum()
	{
		var sum = 0;
		var total = 0;
    var disbursements = 0;
		$('.discount').each(function(i){
			var price = $('.discount').eq(i).text();
			var num = $('.number').eq(i).text();
			sum = parseInt(price) * parseInt(num);
			$('.sum').eq(i).html(sum);
			total += sum ;
			$('.total').html(total)
      disbursements = total - $('.preferential').text();
      $('.disbursements').html(disbursements);
      $('#integral').html(total);
			
		})
	}
	sum();

  $('input[name="back"]').click(function(){
    window.location.href="{:url('shoppingcart')}"; 
  })

  $('input[name="submit"]').click(function(){
    var total = $('.total').eq(0).text();
    var mess = $('input[name="mess"]').val();
    var integral = $('#integral').text();
    if (total==0) {
      alert('您还没有购买商品，请先在商城购买商品')
    }else {
      // window.location.href="{:url('page')}?total="+total+"&integral="+total;
      $.ajax({
        'url':'{:url("page")}',
        'data':'total='+total+'&mess='+mess+'&integral='+integral,
        success:function(res){
          window.location.href="{:url('page')}";
        }

      })
    }
    
  })
</script>
<script type="text/javascript">
function checkLength(which) {
	var maxChars = 50; //
	if(which.value.length > maxChars){
		alert("您出入的字数超多限制!");
		// 超过限制的字数了就将 文本框中的内容按规定的字数 截取
		which.value = which.value.substring(0,maxChars);
		return false;
	}else{
		var curr = maxChars - which.value.length; //250 减去 当前输入的
		document.getElementById("sy").innerHTML = curr.toString();
		return true;
	}
}
</script>
<script>
$(function(){
	$(':input').labelauty();
});
</script>
{/block}

